package com.bluetooth.demo.ui;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bluetooth.demo.MyApplication;
import com.bluetooth.demo.R;
import com.bluetooth.demo.model.Student;

public class GradeFragment extends Fragment {

    private View mCurrentView;
    private TextView tv_grade_tc;
    private TextView tv_grade_zy;
    private TextView tv_grade_ew;
    private TextView tv_grade_zh;

    public GradeFragment() {
        // Required empty public constructor
    }

    public static GradeFragment newInstance() {
        GradeFragment fragment = new GradeFragment();
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        mCurrentView = inflater.inflate(R.layout.fragment_grade, container, false);
        initView(mCurrentView);

        Student student = MyApplication.getInstance().getStudent();
        if (student != null) {

            tv_grade_tc.setText(String.valueOf(student.getTcgrade()));
            tv_grade_zy.setText(String.valueOf(student.getZygrade()));
            tv_grade_ew.setText(String.valueOf(student.getExtra()));
            tv_grade_zh.setText(String.valueOf(student.getLastgrade()));
        }

        return mCurrentView;
    }


    private void initView(View mCurrentView) {
        tv_grade_tc = (TextView) mCurrentView.findViewById(R.id.tv_grade_tc);
        tv_grade_zy = (TextView) mCurrentView.findViewById(R.id.tv_grade_zy);
        tv_grade_ew = (TextView) mCurrentView.findViewById(R.id.tv_grade_ew);
        tv_grade_zh = (TextView) mCurrentView.findViewById(R.id.tv_grade_zh);
    }
}
